$(document).ready(function(){
   $('.order').change(function(){
	   i = $(this);
	   val = (i.val()).split(':');
	   href = i.attr('url') + "?orderby=" + val[0] + "&orderway=" + val[1];
	   window.location.href = href;
   });
   
   if ($('.img_preview').lenght > 0) {
      $('.img_preview').imgPreview({
          // When container is shown:
          onShow: function(link){
              // Animate link:
              $(link).stop().animate({opacity:0.4});
              // Reset image:
              $('img', this).stop().css({opacity:0, border: '2px solid #black'});
          },
          // When image has loaded:
          onLoad: function(){
              // Animate image
              $(this).animate({opacity:1}, 300);
          },
          // When container hides: 
          onHide: function(link){
              // Animate link:
              $(link).stop().animate({opacity:1});
          }
      });
   }
});

function ImgError(source){
    source.src = BASE_URL +"/public/img/noimage.jpg";
    source.onerror = "";
    return true;
}
